package com.flute.icrawler.app.processor.marker;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.flute.icrawler.app.processor.AbstractProcessor;
import com.flute.icrawler.framework.framework.CrawlUrl;
import com.flute.icrawler.framework.framework.container.NumberStringValue;
import com.flute.icrawler.framework.framework.container.AdditionalUrlInformation.Additionals;

public class ResourceIDMarker extends AbstractProcessor {

	private static final Logger LOGGER = LoggerFactory
			.getLogger(ResourceIDMarker.class);

	@Override
	public void process(CrawlUrl url) {
		// TODO Auto-generated method stub
		int id = 0;
		try {
			id = Integer.parseInt(url.getUrl().substring(0, 5));
		} catch (NumberFormatException e) {
			LOGGER.error("{},{}", e, url.getUrl());
		}

		url.getAdditionalUrlInformation().updateValue(Additionals.ResourceID,
				new NumberStringValue(id));
	}
}
